package com.share.mybatis.boot;

import com.share.common.service.BaseService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

import java.sql.SQLException;

/**
 * @desc:
 * @author:caifan
 * @date:2020/11/23
 */
@ComponentScan("com.share.mybatis")
@SpringBootApplication(exclude = JtaAutoConfiguration.class)
public class MybatisBootApplication {

    public static void main(String[] args) throws SQLException  {
        try (ConfigurableApplicationContext applicationContext = SpringApplication.run(MybatisBootApplication.class, args)) {
            BaseService orderService = applicationContext.getBean("orderService", BaseService.class);
            BaseService userService = applicationContext.getBean("userService", BaseService.class);
            orderService.initEnvironment();
            orderService.processSuccess();

            userService.initEnvironment();
            userService.processSuccess();
        }
    }
}
